package hashTable;

public class N383_RansomNote {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] arr = new int[26];
        for (int i = 0; i < magazine.length(); i++)
            arr[magazine.charAt(i) - 'a']++;
        for (int i = 0; i < ransomNote.length(); i++)
            arr[ransomNote.charAt(i) - 'a']--;
        for (int i : arr) {
            if (i < 0)
                return false;
        }
        return true;
    }

    public static void main(String[] args) {
        N383_RansomNote solution = new N383_RansomNote();
        System.out.println(solution.canConstruct("aa", "adf"));
    }
}
